package com.alinesno.cloud.base.notice.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alinesno.cloud.base.notice.entity.SmsSendEntity;
import com.alinesno.cloud.base.notice.service.ISmsSendService;
import com.alinesno.cloud.common.core.constants.SpringInstanceScope;
import com.alinesno.cloud.common.core.monitor.Server;
import com.alinesno.cloud.common.facade.pageable.DatatablesPageBean;
import com.alinesno.cloud.common.web.basic.auth.advice.TranslateCode;
import com.alinesno.cloud.common.web.basic.auth.controller.LocalMethodBaseController;

/**
 * <p>发送管理 前端控制器 </p>
 *
 * @author WeiXiaoJin
 * @since 2020-01-20 12:02:03
 */
@Controller
@Scope(SpringInstanceScope.PROTOTYPE)
@RequestMapping("base/notice/smsSend")
public class SmsSendController extends LocalMethodBaseController<SmsSendEntity, ISmsSendService> {

	//日志记录
	private static final Logger log = LoggerFactory.getLogger(SmsSendController.class);

	@Autowired
	private ISmsSendService smsSendService; 

	@TranslateCode
	@ResponseBody
	@PostMapping("/datatables")
    public DatatablesPageBean datatables(HttpServletRequest request , Model model ,  DatatablesPageBean page){
		log.debug("page = {}" , ToStringBuilder.reflectionToString(page));
		return this.toPage(model, this.getFeign() , page) ;
    }
	
	/**
	 * 基础面板  
	 * @param mmap
	 * @return
	 * @throws Exception
	 */
	@GetMapping("/home")
	public String home(Model model) throws Exception {
		
		long fileCount = 323 ; //storageFileService.count() ; 
		long requestCount = 315 ; //requestService.count() ;
		
		model.addAttribute("fileCount", fileCount) ; 
		model.addAttribute("requestCount", requestCount) ; 
		
		Server server = new Server();
		server.copyTo();
		model.addAttribute("server", server);
	
		return "base/notice/home" ; 
	}

	@Override
	public ISmsSendService getFeign() {
		return this.smsSendService;
	}

}


























